﻿<UserControl x:Class="ProModel.ApplicationFramework.Silverlight.WindowedModalControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:modal="clr-namespace:ProModel.ApplicationFramework.Silverlight" 
    xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
    Width="600" Height="450" MinHeight="100" MinWidth="200" xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
    <UserControl.Resources>

        <Style x:Key="ModalCloseButtonStyle" TargetType="Button">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Grid>
                            <vsm:VisualStateManager.VisualStateGroups>
                                <vsm:VisualStateGroup x:Name="FocusStates">
                                    <vsm:VisualState x:Name="Unfocused"/>
                                    <vsm:VisualState x:Name="Focused"/>
                                </vsm:VisualStateGroup>
                                <vsm:VisualStateGroup x:Name="CommonStates">
                                    <vsm:VisualState x:Name="MouseOver">
                                        <Storyboard>
                                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="Glow" Storyboard.TargetProperty="(UIElement.Opacity)">
                                                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                            </DoubleAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </vsm:VisualState>
                                    <vsm:VisualState x:Name="Normal"/>
                                    <vsm:VisualState x:Name="Pressed"/>
                                    <vsm:VisualState x:Name="Disabled"/>
                                </vsm:VisualStateGroup>
                            </vsm:VisualStateManager.VisualStateGroups>
                            <Canvas>
                                <Rectangle Cursor="Hand" Height="16" x:Name="Outer" Width="45" Fill="{x:Null}" Stroke="#FF570303" StrokeThickness="0.4" RadiusX="0" RadiusY="0"/>
                                <Rectangle Height="13" x:Name="Inner" Width="42" Canvas.Left="1.5" Canvas.Top="1.5" Canvas.ZIndex="0" Stroke="#FF570303" StrokeThickness="0" RadiusX="0" RadiusY="0" Cursor="Hand">
                                    <Rectangle.Fill>
                                        <LinearGradientBrush EndPoint="0.493,1.957" StartPoint="0.491,0">
                                            <GradientStop Color="#FFB11919"/>
                                            <GradientStop Color="#FFFFFFFF" Offset="1"/>
                                        </LinearGradientBrush>
                                    </Rectangle.Fill>
                                </Rectangle>
                                <Rectangle Height="13" Stroke="#FF570303" x:Name="Glow" Width="42" Canvas.Left="1.5" Canvas.Top="1.5" Canvas.ZIndex="0" Opacity="0" StrokeThickness="0" RadiusX="0" RadiusY="0" Cursor="Hand">
                                    <Rectangle.Fill>
                                        <RadialGradientBrush GradientOrigin="0.5,0.559">
                                            <RadialGradientBrush.RelativeTransform>
                                                <TransformGroup>
                                                    <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="1.142" ScaleY="1.164"/>
                                                    <SkewTransform CenterX="0.5" CenterY="0.5"/>
                                                    <RotateTransform CenterX="0.5" CenterY="0.5"/>
                                                    <TranslateTransform Y="0.509" X="0.004"/>
                                                </TransformGroup>
                                            </RadialGradientBrush.RelativeTransform>
                                            <GradientStop Color="#FFFFFFFF"/>
                                            <GradientStop Color="#00FFFFFF" Offset="1"/>
                                            <GradientStop Color="#F0FEFEFE" Offset="0.83"/>
                                        </RadialGradientBrush>
                                    </Rectangle.Fill>
                                </Rectangle>
                                <Rectangle Height="13" Stroke="#FF570303" x:Name="Glass" Width="42" Canvas.Left="1.5" Canvas.Top="1.5" Canvas.ZIndex="0" Opacity="0.75" StrokeThickness="0" RadiusX="0" RadiusY="0" Cursor="Hand">
                                    <Rectangle.Fill>
                                        <LinearGradientBrush EndPoint="0.5,0" StartPoint="0.5,1">
                                            <GradientStop Color="#FFB11919"/>
                                            <GradientStop Color="#FFFFFFFF" Offset="1"/>
                                            <GradientStop Color="#FFE4B1B1" Offset="0.772"/>
                                            <GradientStop Color="#FEBC3A3A" Offset="0.688"/>
                                        </LinearGradientBrush>
                                    </Rectangle.Fill>
                                </Rectangle>
                            </Canvas>
                            <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="VistaMaximizeStyle" TargetType="Button">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Grid>
                            <vsm:VisualStateManager.VisualStateGroups>
                                <vsm:VisualStateGroup x:Name="FocusStates">
                                    <vsm:VisualState x:Name="Unfocused"/>
                                    <vsm:VisualState x:Name="Focused"/>
                                </vsm:VisualStateGroup>
                                <vsm:VisualStateGroup x:Name="CommonStates">
                                    <vsm:VisualState x:Name="MouseOver">
                                        <Storyboard>
                                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="Glow" Storyboard.TargetProperty="(UIElement.Opacity)">
                                                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="Glow2" Storyboard.TargetProperty="(UIElement.Opacity)">
                                                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.2"/>
                                            </DoubleAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </vsm:VisualState>
                                    <vsm:VisualState x:Name="Normal"/>
                                    <vsm:VisualState x:Name="Pressed"/>
                                    <vsm:VisualState x:Name="Disabled"/>
                                </vsm:VisualStateGroup>
                            </vsm:VisualStateManager.VisualStateGroups>
                            <Canvas>
                                <Rectangle Height="16" x:Name="Outer" Width="24" Fill="#00FFFFFF" Stroke="#FF4C4C4F" StrokeThickness="0.4" Opacity="0.4"/>
                                <Rectangle Height="13" Width="21" Stroke="{x:Null}" StrokeThickness="0.4" x:Name="Inner" Canvas.Left="1.5" Canvas.Top="1.5">
                                    <Rectangle.Fill>
                                        <LinearGradientBrush EndPoint="0.499,1.776" StartPoint="0.5,0">
                                            <GradientStop Color="#FFADB9C6"/>
                                            <GradientStop Color="#FFFFFFFF" Offset="1"/>
                                        </LinearGradientBrush>
                                    </Rectangle.Fill>
                                </Rectangle>
                                <Rectangle Height="13" Width="21" Stroke="{x:Null}" StrokeThickness="0.4" x:Name="Glow" Canvas.Left="1.5" Canvas.Top="1.5" Opacity="0">
                                    <Rectangle.Fill>
                                        <LinearGradientBrush EndPoint="0.5,0" StartPoint="0.5,1">
                                            <GradientStop Color="#FF1B6DA6"/>
                                            <GradientStop Color="#FFC2E2F7" Offset="1"/>
                                            <GradientStop Color="#FF5F9DC7" Offset="0.54"/>
                                            <GradientStop Color="#FF2A77AD" Offset="0.487"/>
                                        </LinearGradientBrush>
                                    </Rectangle.Fill>
                                </Rectangle>
                                <Rectangle Height="13" Width="21" Stroke="{x:Null}" StrokeThickness="0.4" x:Name="Glass" Canvas.Left="1.5" Canvas.Top="1.5" Opacity="0.5">
                                    <Rectangle.Fill>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                            <GradientStop Color="#FFFFFFFF"/>
                                            <GradientStop Color="#FF6E747C" Offset="1"/>
                                            <GradientStop Color="#FF7F858E" Offset="0.567"/>
                                            <GradientStop Color="#FEABB7C4" Offset="0.429"/>
                                        </LinearGradientBrush>
                                    </Rectangle.Fill>
                                </Rectangle>
                                <Rectangle Height="13" Width="21" Stroke="{x:Null}" StrokeThickness="0.4" x:Name="Glow2" Opacity="0" Canvas.Left="1.5" Canvas.Top="1.5">
                                    <Rectangle.Fill>
                                        <RadialGradientBrush>
                                            <RadialGradientBrush.RelativeTransform>
                                                <TransformGroup>
                                                    <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="1.438" ScaleY="1.185"/>
                                                    <SkewTransform CenterX="0.5" CenterY="0.5"/>
                                                    <RotateTransform CenterX="0.5" CenterY="0.5"/>
                                                    <TranslateTransform X="0.008" Y="0.41200000047683716"/>
                                                </TransformGroup>
                                            </RadialGradientBrush.RelativeTransform>
                                            <GradientStop Color="#FFFFFFFF" Offset="0"/>
                                            <GradientStop Color="#00FFFFFF" Offset="1"/>
                                        </RadialGradientBrush>
                                    </Rectangle.Fill>
                                </Rectangle>
                            </Canvas>
                            <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <LinearGradientBrush x:Key="FormBackgroundBrush" EndPoint="0.5,2" StartPoint="1,0">
            <GradientStop Color="AliceBlue"/>
            <GradientStop Color="LightBlue" Offset="1"/>
        </LinearGradientBrush>        
        <LinearGradientBrush x:Key="TitleBarBackgroundBrush" EndPoint="0.5,-1.55" StartPoint="0.59,2.25">
            <GradientStop Color="#FF7086AB" Offset="0.0040000001899898052"/>
            <GradientStop Color="#FF5D738A" Offset="1"/>
        </LinearGradientBrush>

    </UserControl.Resources>
    
        <Grid x:Name="LayoutRoot" Background="Transparent" MinHeight="50" MinWidth="50">
        
        <!-- Start BackgroundFrame Border-->
        <Border x:Name="FrameBorder" Height="Auto" Width="Auto" CornerRadius="10,10,0,10" Background="{StaticResource FormBackgroundBrush}" BorderThickness="1" BorderBrush="Black">
            <Grid>
                <!-- Start TitleBar-->
                <Border x:Name="TitleBar" Height="20" Width="Auto" VerticalAlignment="Top" Margin="0,0,0,0" CornerRadius="9.5,9.5,0,0" 
                        BorderThickness="0" BorderBrush="Black" Background="{StaticResource TitleBarBackgroundBrush}">
                </Border>
                <!-- End TitleBar-->

                <!-- Start Content Panel-->
                <toolkit:DockPanel x:Name="_userPanel" Margin="12,27,12,45" Background="Transparent" LastChildFill="True"></toolkit:DockPanel>
                <!-- End Content Panel-->
                
                <!-- Start Dialog Buttons-->
				<ContentControl TabNavigation="Cycle" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,6,6">
                <StackPanel Orientation="Horizontal">
                <Button Width="Auto" MinWidth="90" Height="33" Click="btnClick" HorizontalAlignment="Right" Margin="0,0,5,0" VerticalAlignment="Bottom" Content="OK" x:Name="btnOK"/>
                <Button Width="Auto" MinWidth="90" Height="33" Click="btnClick" HorizontalAlignment="Right" Margin="0,0,5,0" VerticalAlignment="Bottom" Content="Cancel" x:Name="btnCancel"/>
                <Button Width="Auto" MinWidth="90" Height="33" Click="btnClick" HorizontalAlignment="Right" Margin="0,0,5,0" VerticalAlignment="Bottom" Content="Apply" x:Name="btnApply"/>
                </StackPanel>
				</ContentControl>
                <!-- End Dialog Buttons-->

                <!--<TextBlock x:Name="coordinates" Text="Coordinates: 0,0" VerticalAlignment="Bottom" Margin="13,0,100,20"/>
                <TextBlock x:Name="offset" Text="Offset: 0,0" VerticalAlignment="Bottom" Margin="13,0,100,6"/>-->

                <!-- Start Corner Rezise Handle-->
                <Path x:Name="DragCorner" Fill="{StaticResource TitleBarBackgroundBrush}" Stretch="Fill" StrokeLineJoin="Round" Stroke="{x:Null}" Data="F1 M 483.126,293.584L 483.08,149.061L 333.207,293.584" Height="9" HorizontalAlignment="Right" Margin="0,0,0,0" VerticalAlignment="Bottom" Width="9.303" d:LayoutOverrides="Width" Cursor="Hand">
            		<!--<Path.Fill>
            			<LinearGradientBrush EndPoint="0.733,0.889" StartPoint="0.559,-0.009">
            				<GradientStop Color="#FF5A7FA3" Offset="0.004"/>
            				<GradientStop Color="#FF5D738A" Offset="1"/>
            			</LinearGradientBrush>
            		</Path.Fill>-->
            	</Path>
                <!-- End Corner Rezise Handle-->
                
                <!-- Start TitleBar buttons-->
            	<StackPanel x:Name="stkButtonPanel" Height="16" HorizontalAlignment="Right" Margin="0,2,12,0" VerticalAlignment="Top" Width="69" Orientation="Horizontal" Background="#00FFFFFF">

                    <Button x:Name="btnMaximize" Height="16" HorizontalAlignment="Left" Click="btnMaximize_Click" Style="{StaticResource VistaMaximizeStyle}" VerticalAlignment="Top" Width="24">
                        <Path Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF535666" Fill="#FFFFFFFF" Data="M 69,61.25L 245.375,61.25L 245.375,211.25L 69,211.25L 69,61.25 Z M 104.275,91.25L 210.1,91.25L 210.1,181.25L 104.275,181.25L 104.275,91.25 Z " Height="11" Width="14" RenderTransformOrigin="0.5,0.5" StrokeThickness="0.4">
                            <Path.RenderTransform>
                                <TransformGroup>
                                    <ScaleTransform/>
                                    <SkewTransform/>
                                    <RotateTransform/>
                                    <TranslateTransform Y="-0.3"/>
                                </TransformGroup>
                            </Path.RenderTransform>
                        </Path>
                    </Button>
                    <Button x:Name="btnClose" Click="btnClick" Height="16" Width="45" Style="{StaticResource ModalCloseButtonStyle}" HorizontalAlignment="Right">
            			<Path Stretch="Fill" StrokeThickness="0.4" StrokeLineJoin="Round" Stroke="#FF570303" Fill="#FFFFFFFF" Data="F1 M 71.5,57.8109L 68.5006,57.8109L 66.4394,54.597L 64.2996,57.8109L 61.4467,57.8109L 64.9556,52.8118L 61.5825,47.8934L 64.5735,47.8934L 66.5604,50.9289L 68.6407,47.8934L 71.5,47.8934L 68.0527,52.7014L 71.5,57.8109 Z " Height="10" Width="13"/>
            		</Button>

                </StackPanel>
            	<Image Height="16" HorizontalAlignment="Left" Margin="9,2,0,0" VerticalAlignment="Top" Width="16" Grid.Row="36" x:Name="_imgTitleImage"/>
                <!-- End TitleBar buttons-->

            </Grid>
        </Border>
        <!-- End BackgroundFrame Border-->

        <!-- Start TitleBar Text-->
        <TextBlock x:Name="tblTitleBar" Height="14" Foreground="#FFFDF7F7" HorizontalAlignment="Left" Margin="31,3,0,0" VerticalAlignment="Top" Text="TitleBar Text"  FontWeight="Normal" FontFamily="Portable User Interface" />
        <!-- End TitleBar -->


        <!-- Start Resize Rects-->
        <Rectangle Height="3" Margin="10,0,10,1" VerticalAlignment="Bottom" Fill="#00FFFFFF" Stroke="{x:Null}" Cursor="SizeNS" x:Name="BottomResizeRect"/>
        <Rectangle Cursor="SizeNS" Height="3" Margin="10,1,10,0" VerticalAlignment="Top" Fill="#00FFFFFF" Stroke="{x:Null}" d:LayoutOverrides="GridBox" x:Name="TopResizeRect"/>
        <Rectangle HorizontalAlignment="Left" Margin="1,10,0,10" Width="3" Fill="#00FFFFFF" Stroke="{x:Null}" Cursor="SizeWE" x:Name="LeftResizeRect"/>
        <Rectangle HorizontalAlignment="Right" Margin="0,10,1,10" Width="3" Fill="#00FFFFFF" Stroke="{x:Null}" Cursor="SizeWE" x:Name="RightResizeRect"/>    
        <!-- End Resize Rects-->

    </Grid>
</UserControl>
